#include "Singleton.h"
#include <atomic>
#include <mutex>

Singleton* Singleton::m_instance = NULL;
Singleton::_Inner Singleton::m_innert = _Inner();
std::atomic_int count(0);
std::mutex mylock;

Singleton::Singleton(void)
{
    count++;
    printf("***************create Singleton instance, count :%d\n", count.load());
}


Singleton::~Singleton(void)
{
    count--;
    printf("***************destory Singleton instance, count :%d\n", count.load());
}


Singleton* Singleton::GetInstance()
{
    if (m_instance == nullptr)
    {
        mylock.lock();
        if (nullptr == m_instance)
        {
            m_instance = new Singleton;
        }
        mylock.unlock();
    }

    return m_instance;
}